import Vue from 'vue'
import VueI18n from 'vue-i18n'
import elementEnLocale from 'element-ui/lib/locale/lang/en' // element-ui lang
import elementZhLocale from 'element-ui/lib/locale/lang/zh-CN'// element-ui lang
import elementKoLocale from 'element-ui/lib/locale/lang/ko'// element-ui lang
import enLocale from './en'
import zhLocale from './zh'
import koLocale from './ko'


Vue.use(VueI18n)
var elementKey = ['enLocale' , 'zhLocale' , 'koLocale']
const localeKeys = ['en', 'zh' , 'ko']
// 各个国家语言包
const messages = {
  en: {
    ...enLocale,
    ...elementEnLocale
  },
  zh: {
    ...zhLocale,
    ...elementZhLocale
  },
  ko: {
    ...koLocale,
    ...elementKoLocale
  }

}


export function getLanguage() {
  let lang = localStorage.getItem("lang");
  if(lang){
    return lang
  }else{
    return 'zh'
  }

}

export default new VueI18n({
    locale: getLanguage(),
    messages,
    silentTranslationWarn: true // 忽略翻译警告
})

